//用户相关的后端api

import serviceAxios from '@/utils/serviceAxios.js'

//定义的同时导出函数，先定义，后导出
//判断当前用户名是否可用，用户名是否已经被占用 =》get=>/check/:username
export const checkUsername = (username) => {
	return serviceAxios({
		url: "/check/" + username,
		methon: "get",
	})
}
//用户注册
export const createUser = (data) => {
	return serviceAxios({
		//请求地址
		url: "/user",
		method: "post",
		data: data
	})
}
export const login = (data) => {
	return serviceAxios({
		//请求地址
		url: "/auth/login",
		//请求方式
		method: "post",
		//post参数
		data: data
	})
}

//获取用户信息 /user/username
export const getUserinfo = (username) => {
	return serviceAxios({
		url: "/user/" + username,
		method: "get"
	})
}

export const uploadAvator = (username, data) => {
	return serviceAxios({
		url: "/user/" + username + "/avator",
		method: "post",
		data: data
	})

}

export const logout = (params) => {
	return serviceAxios({
		url: "/auth/logout",
		method: "get",
		params: params
		//params
	})
}
